const path = require('path')
const commonConfig = require('./webpack.config')
const {merge} = require('webpack-merge')
const {CleanWebpackPlugin} = require('clean-webpack-plugin')

const prodConfig = {
  mode: 'production', // 生产环境
  devtool: 'source-map',
  output: {
    filename: 'PacktDataStructuresAlgorithms.min.js',  // 输出文件名，一般要加上hash
    path: path.resolve(__dirname,'lib')  // 输出目录
  },
  module: {
    rules: [
      {
        test: /\.(ts|js)x?$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
    },
    ]
  },
  plugins: [
    new CleanWebpackPlugin()
  ]
}

module.exports = merge(commonConfig, prodConfig)
